﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Scan
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
      
        private void menuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void menuItem6_Click(object sender, EventArgs e)
        {
           
        }

        private void pBruku_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmWl wl = new frmWl(OperationClass.ruku);
                wl.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.ruku);
                frmlogin.ShowDialog();
            }
        }

        private void pBchuku_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmWl wl = new frmWl(OperationClass.cuku);
                wl.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.cuku);
                frmlogin.ShowDialog();
            }
        }

        private void pBzuangxiang_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmXiang xiang = new frmXiang(OperationClass.zhuangxiang);
                xiang.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.zhuangxiang);
                frmlogin.ShowDialog();
            }
        }

        private void pBcaixiang_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmXiang xiang = new frmXiang(OperationClass.caixiang);
                xiang.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.caixiang);
                frmlogin.ShowDialog();
            }
        }

        private void pBbuxiang_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmXiang xiang = new frmXiang(OperationClass.buxiang);
                xiang.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.buxiang);
                frmlogin.ShowDialog();
            }
        }

        private void pBfenli_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmXiang xiang = new frmXiang(OperationClass.fenli);
                xiang.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.fenli);
                frmlogin.ShowDialog();
            }
        }

        private void pBliechuall_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmWl wl = new frmWl(OperationClass.tuihuo);
                wl.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.tuihuo);
                frmlogin.ShowDialog();
            }
        }

        private void pBfw_Click(object sender, EventArgs e)
        {
            frmwlQuery fwq = new frmwlQuery(FwWlClass.fw);
            fwq.ShowDialog();
        }

        private void pBwl_Click(object sender, EventArgs e)
        {
            frmwlQuery fwq = new frmwlQuery(FwWlClass.wl);
            fwq.ShowDialog();
        }

        private void menuItem5_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(PublicVar.StrBanBen);
            sb.Append("\r\n");
            sb.Append(PublicVar.StrRiQi);
            MessageBox.Show(sb.ToString());
        }

        private void menuItem3_Click(object sender, EventArgs e)
        {
            frmSelectSb fss = new frmSelectSb(1);
            fss.ShowDialog();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                PublicVar.WLURL = edit_config.ConfigGetValue("ServerUrl") + "/FlManger.asmx";
                PublicVar.FWURL = edit_config.ConfigGetValue("ServerUrl") + "/fwwlCode.asmx";
                PublicVar.USERURL = edit_config.ConfigGetValue("ServerUrl") + "/User.asmx";
                PublicVar.JXSURL = edit_config.ConfigGetValue("ServerUrl") + "/Jxs.asmx";
                PublicVar.CPURL = edit_config.ConfigGetValue("ServerUrl") + "/SetCp.asmx";
                PublicVar.WAREHOUSEURL = edit_config.ConfigGetValue("ServerUrl") + "/Warehouse.asmx";
                PublicVar.ISURL = edit_config.ConfigGetValue("ServerUrl") + "/IntegralServer.asmx";
                PublicVar.IsThreadAutoRun = Convert.ToBoolean(edit_config.ConfigGetValue("isThreadAutoRun"));
                PublicVar.IsAutoAddWlCode = Convert.ToBoolean(edit_config.ConfigGetValue("isAutoAddWlCode"));
                PublicVar.autoAddWlCode = edit_config.ConfigGetValue("autoAddWlCode");
                PublicVar.InterceptStr = edit_config.ConfigGetValue("interceptStr");

                this.Text = edit_config.ConfigGetValue("TitleName");

                string _setBeiName = edit_config.ConfigGetValue("SeiBeiName");

                if (_setBeiName == "新大陆")
                {
                    PublicVar.SeiBei = SeiBeiClass.xindalu;
                }
                else if (_setBeiName == "宝迅")
                {
                    PublicVar.SeiBei = SeiBeiClass.baoxun;
                }
                else if (_setBeiName == "东大集成一维")
                {
                    PublicVar.SeiBei = SeiBeiClass.AutoIDOne;
                }
                else if (_setBeiName == "东大集成")
                {
                    PublicVar.SeiBei = SeiBeiClass.AutoID;
                }
                else
                {
                    PublicVar.SeiBei = SeiBeiClass.YinDaJuLi;
                }

                if (edit_config.ConfigGetValue("IsCheckDistinct") == "0")
                {
                    PublicVar.IsCheckDistinct = false;
                }
                else
                {
                    PublicVar.IsCheckDistinct = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmfwwlhucha fwwlhucha = new frmfwwlhucha();
                fwwlhucha.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.buxiang);
                frmlogin.ShowDialog();
            }
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmIntegral frmintegral = new frmIntegral();
            frmintegral.ShowDialog();
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
            if (PublicVar.IsLogin)
            {
                frmXiang xiang = new frmXiang(OperationClass.liechuall);
                xiang.ShowDialog();
            }
            else
            {
                frmLogin frmlogin = new frmLogin(OperationClass.liechuall);
                frmlogin.ShowDialog();
            }
        }
    }
}